<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script src="./vue.js"></script>

    <div id="app">
      <h1>vue初体验</h1>
      <h5>遍历数组</h5>
      <ul>
        <!-- item是值,index是键 -->
        <li v-for="item,index in arr" :key="index">{{item}}-{{index}}</li>
      </ul>
      <h5>遍历对象</h5>
      <ul>
        <li v-for="item,index in obj" :key="index">{{item}}-{{index}}</li>
      </ul>
      <h5>遍历字符串</h5>
      <ul>
        <li v-for="item,index in str" :key="index">{{item}}-{{index}}</li>
      </ul>
      <h5>遍历数字</h5>
      <ul>
        <li v-for="item,index in 5" :key="index">{{item}}-{{index}}</li>
      </ul>
    </div>

    <script>
      Vue.config.productionTip = false
      const vm = new Vue({
        // el绑定模板
        el: '#app',
        //data定义模板中要使用的数据
        data: {
          arr: ['a', 'b', 'c'],
          obj: {
            name: 'zs',
            age: 18,
          },
          str: 'xyz',
          num: 5,
        },
      })
    </script>
  </body>
</html>
